<?php
namespace DRY\Module;

/**
 * DonReY Framework 2012 :: Locator is used to match various types of arbitrary data (usually strings, arrays of strings or numbers) to a precise ID
 * - Useful in building a CMS, online shop, etc., where an arbitrary URL is used to locate a resource (example: /components/storage/hdd/seagate-1tb becomes product #731)
 * The Models convert the input data into an item ID, using various methods
 *
 * @author Wavetrex <wavetrex@gmail.com>
 * @link http://www.donrey.net/Documentation/Structure/Modules/locator.html
 * @license [GPL v3] http://www.gnu.org/licenses/gpl-3.0.html
 * @version 1.0.dev
 * @package DonReY
 * @subpackage Module.Locator
 */
class Locator extends base
{
	// Autoloader configuration
	const
		Autoload_Directory = 'locator',
		Autoload_Prefix = 'DRY\Locator\Model',
		Autoload_Suffix = 'model'
		;

	/**
	 * Instances a "Document Model" object
	 * @param string $reference Model reference inside the module's configuration
	 * @param mixed $id Identifier for this document
	 * @param mixed $params Extra parameters for the Model
	 * @return \DRY\Document\base
	 */
	public function factory_Model($reference, $params = null)
	{
		$model_type = (string)$this-> CFG-> models-> {$reference}['model'];
		if(empty($model_type))
			return null; // when no valid type found in CFG
		$content_class = self::Autoload_Prefix.'_'.$model_type;
		return new $content_class($this, $this-> CFG-> models-> $reference, $params);
	}

}

namespace DRY\Locator;

/**
 * Locator model
 *
 * @author Wavetrex <wavetrex@gmail.com>
 * @link http://www.donrey.net/Documentation/Structure/Modules/document.html
 * @license [GPL v3] http://www.gnu.org/licenses/gpl-3.0.html
 * @version 1.0.dev
 * @package DonReY
 * @subpackage Module.Locator
 */
abstract class Model_base
{
	abstract function locate($input);
}